<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>

</body>
<script>
  /*张云如意*/
  function qSort(arr) {
    if (arr.length <= 1) return arr;
    let left = [];
    let right = [];
    let mid = arr[0];
    for (let i = 1; i < arr.length; i++) {
      if (mid > arr[i]) {
        left.push(arr[i])
      } else {
        right.push(arr[i])
      }
    }
    return ([...qSort(left), mid, ...qSort((right))])
  }

  console.log(qSort([2, 3, 4, 1, 2]))
</script>
</html>
